package cn.qm.service;

import cn.qm.dao.MedicalAdviceMapper;
import cn.qm.pojo.MedicalAdvice;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
* Created by shang-pc on 2018/5/15.
*/
@RestController
public class MedicalAdviceClient {
    @Resource
    private MedicalAdviceMapper medicalAdviceMapper;
    @RequestMapping(value = "/getMedicalAdviceById",method = RequestMethod.POST)
    public MedicalAdvice getMedicalAdviceById(@RequestParam Long id)throws Exception{
        return medicalAdviceMapper.getMedicalAdviceById(id);
    }

    @RequestMapping(value = "/getMedicalAdviceListByMap",method = RequestMethod.POST)
    public List<MedicalAdvice> getMedicalAdviceListByMap(@RequestBody Map<String,Object> param)throws Exception{
        return medicalAdviceMapper.getMedicalAdviceListByMap(param);
    }

    @RequestMapping(value = "/getMedicalAdviceCountByMap",method = RequestMethod.POST)
    public Integer getMedicalAdviceCountByMap(@RequestBody Map<String,Object> param)throws Exception{
        return medicalAdviceMapper.getMedicalAdviceCountByMap(param);
    }

    @RequestMapping(value = "/qmtxAddMedicalAdvice", method = RequestMethod.POST)
    public Integer qmtxAddMedicalAdvice(@RequestBody MedicalAdvice medicalAdvice) throws Exception {
        medicalAdvice.setCreatedTime(new Date());
        return medicalAdviceMapper.insertMedicalAdvice(medicalAdvice);
    }

    @RequestMapping(value = "/qmtxModifyMedicalAdvice",method = RequestMethod.POST)
    public Integer qmtxModifyMedicalAdvice(@RequestBody MedicalAdvice medicalAdvice)throws Exception{
        medicalAdvice.setUpdatedTime(new Date());
        return medicalAdviceMapper.updateMedicalAdvice(medicalAdvice);
    }

    @RequestMapping(value = "/qmtxDeleteMedicalAdviceById",method = RequestMethod.POST)
    public Integer qmtxDeleteMedicalAdviceById(@RequestParam Long id)throws Exception{
        return medicalAdviceMapper.deleteMedicalAdviceById(id);
    }

    @RequestMapping(value = "/queryMedicalAdvicePageByMap",method = RequestMethod.POST)
    public Page<MedicalAdvice> queryMedicalAdvicePageByMap(@RequestBody Map<String,Object> param, Integer pageNo, Integer pageSize)throws Exception{
        return null;
    }
}
